import 'package:flutter/material.dart';
import 'package:fluwx/fluwx.dart';
import 'package:get/get.dart';
import 'package:url_launcher/url_launcher_string.dart';
import '../../../controller/service/resource_service.dart';
import '../../../resources/colours.dart';
import '../../../resources/styles.dart';
import '../../../utils/image_utils.dart';
import '../../../widgets/base/qkd_text.dart';
import '../../../widgets/base/qkd_image.dart';

class ExpertContactCode extends StatelessWidget {
  const ExpertContactCode({super.key});

  @override
  Widget build(BuildContext context) {
    final resource = Get.find<ResourceService>();
    return Column(
      children: [
        QkdText("官方客服QQ", fontSize: 16, fontWeight: FontWeight.w500),
        Container(height: 8),
        QkdImage(
          imageUrl: resource.expertCS?.imgUrl,
          width: 150,
          height: 150,
          errorWidget: Styles.placeholderIcon(),
        ),
        Container(height: 16),
        GestureDetector(
          onTap: () async {
            var result = await ImageUtils.saveImageToGallery(
                url: resource.expertCS?.imgUrl);
            if (result == true) {
              await Future.delayed(const Duration(milliseconds: 300));
              launchUrlString('mqq://');
              // Fluwx().open(target: WeChatApp());
            }
          },
          child: Container(
              padding: const EdgeInsets.symmetric(horizontal: 26, vertical: 11),
              decoration: BoxDecoration(
                  border: Border.all(color: Colours.main, width: 0.5),
                  borderRadius: BorderRadius.circular(8)),
              child: QkdText('保存二维码，并打开QQ', fontSize: 16, color: Colours.main)),
        )
      ],
    );
  }
}
